import { ref } from 'vue'

const times = ref(null) as any

// timerFun(ceShi, 1000)(); 调用方式

// 定时器
const timerFun = (f: any, time: any) => {
  return function backFun() {
    clearTimeout(times.value)

    times.value = setTimeout(function () {
      f()
      backFun()
    }, time)
  }
}

// 销毁
const destroyTime = () => {
  clearTimeout(times.value)
}

export { timerFun, destroyTime }
